// pages/component/homes/help/homehelp/homehelp.js
var dataManager = require('../../../../../utils/dataManager.js');
var GlobalData = require('../../../../../utils/GlobalData.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    businessMsg: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  dataManager.removeBtnObserver("homehelp")

    if (GlobalData.homeData && GlobalData.homeData.businessname)
      this.setData({
        businessMsg: GlobalData.homeData.businessname
      })
    else if (!GlobalData.homeData.businessname)
      this.setData({
        businessMsg: "(您还没有商务代表)"
      })
  },
  /**前往sp */
  goPromotionViedo: function () {
      if (dataManager.isClick("promotiomViedo")) {
      return
    } else {
      dataManager.btnObserver("promotiomViedo")
      dataManager.UseNavigateTo('../../../homes/help/promotiomViedo/promotiomViedo', false);
    }
   
  },
  /**常见问题 */
  goIssue: function () {
  },
  /**政策 */
  goPolicy: function () {
    // dataManager.UseNavigateTo('../../../homes/help/promotiomViedo/promotiomViedo', false);
  },
  /**复制商务代表 */
  copyTxt: function () {
    // var str = ""
    var that = this
    if (GlobalData.homeData && GlobalData.homeData.businessname)
      that.setData({
        businessMsg: GlobalData.homeData.businessname
      })
    // that.data.businessMsg = GlobalData.homeData.businessname
    else if (!that.data.businessMsg)
      that.setData({
        businessMsg: "(您还没有商务代表)"
      })
    wx.setClipboardData({
      data: that.data.businessMsg,
      success() {
        wx.getClipboardData({
          success(res) {
            app.show("已复制成功。")
          }
        })
      },
      fail(res) {
        console.error(res)
      }
    })
  },
  /**打电话 */
  call: function () {
    wx.makePhoneCall({
      phoneNumber: '400-1666-173', //此号码并非真实电话号码，仅用于测试  
      success: function () {
        console.log("拨打电话成功！")
      },
      fail: function () {
        console.log("拨打电话失败！")
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})